package cn.edu.nju.software.cdiy.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import cn.edu.nju.software.cdiy.bean.Brand;
import cn.edu.nju.software.cdiy.bean.Disk;
import cn.edu.nju.software.cdiy.bean.Hardware;
import cn.edu.nju.software.cdiy.bean.HardwareSet;
import cn.edu.nju.software.cdiy.bean.Scheme;
import cn.edu.nju.software.cdiy.dao.DiskDao;
import cn.edu.nju.software.cdiy.dao.SchemeDao;
import cn.edu.nju.software.cdiy.service.Service;
import cn.edu.nju.software.cdiy.service.UtilService;
import cn.edu.nju.software.cdiy.util.BusinessConstant;
import cn.edu.nju.software.cdiy.util.Item;
import cn.edu.nju.software.cdiy.util.SortType;
import cn.edu.nju.software.cdiy.util.SortWay;

public class DiskServiceImpl implements Service<Disk>{
	
	@Autowired
	private DiskDao diskDao;
	@Autowired
	private SchemeDao schemeDao;
	@Autowired
	private UtilService utilService;

	public void setDiskDao(DiskDao diskDao) {
		this.diskDao = diskDao;
	}

	public void setSchemeDao(SchemeDao schemeDao) {
		this.schemeDao = schemeDao;
	}

	public void setUtilService(UtilService utilService) {
		this.utilService = utilService;
	}

	public List<Disk> getDiskList(int page,SortType s,HardwareSet hs,SortWay sw){
		return diskDao.getDiskList(page, s, utilService.fillHardwareSet(hs), sw);
	}
	
	public List<Hardware> getNewestList() {
		return diskDao.getNewestList();
	}
	
	public List<Hardware> getHottestList() {
		return diskDao.getHottestList();
	}
	
	public List<Brand> getBrandList() {
		return diskDao.getBrandList();
	}
	
	public List<Disk> filter(int page,Map<String, List<Integer>> map,SortType st,SortWay sw,HardwareSet hs) {
		return diskDao.filter(page, map, st, sw, utilService.fillHardwareSet(hs));
	}
	
	public List<Disk> search(String keywords,int page) {
		return diskDao.search(keywords, page);
	}
	
	public Map<String,List<Item>> getFilterBoard() {
		return diskDao.getFilterBoard();
	}
	
	public Disk getOneById(int id) {
		return diskDao.getOneById(id);
	}
	
	public Map<String, List<String>> getInsertboard() {
		return diskDao.getInsertboard();
	}
	
	public boolean insertHardware(Map<String, List<String>> map) {
		return diskDao.insertHardware(map);
	}
	
	public void save(Disk t) {
		diskDao.save(t);
	}
	
	public int getFilterResultLength(Map<String, List<Integer>> map,HardwareSet hs) {
		return diskDao.filterPageNum(map, utilService.fillHardwareSet(hs));
	}
	
	public int getListPageNum(HardwareSet hs) {
		return diskDao.getListPageNum(utilService.fillHardwareSet(hs));
	}

	@Override
	public List<Scheme> getRelatedSchemes(int hardwareId) {
		return schemeDao.getFourScheme(hardwareId, BusinessConstant.H_DISK);
	}
	
	@Override
	public List<Disk> getSupplierHarewares(int id) {
		// TODO Auto-generated method stub
		return diskDao.getOneBySupplierID(id);
	}
}
